aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/types/[...id].astro
blob: 0215eba756bb70d28a77f63e4b894a78d53fd6e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
import Breadcrumbs from '@/components/Breadcrumbs.astro'
import PageHead from '@/components/PageHead.astro'
import Layout from '@/layouts/Layout.astro'
import { getAllTypes, getEventsByType } from '@/lib/data-utils'
import { capitalizeFirstLetter, iconMappings } from '@/lib/utils'
import EventCard from '../../components/EventCard.astro'

export async function getStaticPaths() {
  const typeMap = await getAllTypes()
  const uniqueTags = Array.from(typeMap.keys())

  return Promise.all(
    uniqueTags.map(async (type) => {
      const events = await getEventsByType(type)
      return {
        params: { id: type },
        props: {
          type,
          events,
        },
      }
    }),
  )
}

const { type, events } = Astro.props
---

<Layout class="max-w-3xl">
  <PageHead
    slot="head"
    title={`${capitalizeFirstLetter(type)} Events`}
    description={`A collection of ${type} events.`}
    noindex
  />
  <Breadcrumbs
    items={[
      { href: '/types', label: 'Event types', icon: 'lucide:calendar-days' },
      { label: type, icon: iconMappings[type] || 'lucide:ticket' },
    ]}
  />

  <ul class="flex flex-col gap-y-4">
    {
      events.map((event) => (
        <li>
          <EventCard entry={event} />
        </li>
      ))
    }
  </ul>
</Layout>